import '../css/a.css';
import '../css/b.css';
import { mul } from '../../../16.treeshaking/src/js/test';

function sum(...args) {
  return args.reduce((p, c) => p + c, 0);
}

// eslint-disable-next-line
console.log(mul(2, 3))
// eslint-disable-next-line
console.log(sum(1, 2, 3, 4));


/**
 * 问题：
 * 1. eslint不认识window、navigator全局变量
 * 解决： package.json中修改配置
 *    "env": {
 *      "browser": true
 *     }
 * 2. sw代码必须运行在服务器上
 *    --> nodejs
 *    --> 
 *      npm i serve -g
 *      serve -s build : 启动服务器，将build目录下所有的资源作为静态资源暴露出去
 */


// 注册servicework

// 兼容性处理
if ('serviceworkder' in navigator) {
  window.addEventListener('load', () => {
    navigator.serviceWorker.register('/service-worker.js')
      .then(() => {
        console.log('sw注册成功');
      })
      .catch(() => {
        console.log('sw注册失败');
      });
  });
}
